<template>
  <el-container>
    <el-header>
      <div>
        <img class="logo" src="../assets/马里奥.png"/>
        <span class="info">智贵电商系统后台</span>
      </div>
      <div>
        <el-button type="info" @click="logoutFun">注销</el-button>
      </div>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <el-menu
            active-text-color="#ffd04b"
            background-color="#545c64"
            class="el-menu-vertical-demo"
            :default-active="activePath"
            text-color="#fff"
            @open="handleOpen"
            @close="handleClose"
            :router="true"
            :select="selectFun"
        >
          <el-sub-menu index="1">
            <template #title>
              <el-icon>
                <Location/>
              </el-icon>
              <span>用户管理</span>
            </template>
            <el-menu-item index="/userlist">用户列表</el-menu-item>
            <el-menu-item index="/useradd">用户添加</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="2">
            <template #title>
              <el-icon>
                <Location/>
              </el-icon>
              <span>角色管理</span>
            </template>
            <el-menu-item index="2-1">角色列表</el-menu-item>
            <el-menu-item index="2-2">角色添加</el-menu-item>
            <el-menu-item index="2-3">角色修改</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="3">
            <template #title>
              <el-icon>
                <Location/>
              </el-icon>
              <span>权限管理</span>
            </template>
            <el-menu-item index="3-1">权限列表</el-menu-item>
            <el-menu-item index="3-2">权限添加</el-menu-item>
            <el-menu-item index="3-3">权限修改</el-menu-item>
          </el-sub-menu>

          <el-sub-menu index="4">
            <template #title>
              <el-icon>
                <Location/>
              </el-icon>
              <span>支付管理</span>
            </template>
            <el-menu-item index="/index/payList">支付列表</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import {testFun} from "../api/test.js";

import {
  Document,
  Menu as IconMenu,
  Location,
  Setting,
} from '@element-plus/icons-vue'

export default {
  name: "Index"
  , data() {
    return {
      activePath: '/index'
    }
  }
  , methods: {
    selectFun(index,indexPath){
      // console.log(index);
      // console.log(indexPath);
      this.activePath = indexPath[1];
    },
    handleOpen(key, keyPath) {
      // console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath)
    },
    async clickFun() {
      const {data: ret} = await testFun();
      console.log(ret);
    },
    logoutFun() {
      console.log("注销");
      //清除sessionStorage
      sessionStorage.removeItem("token");
      //跳转到登录页面
      window.location.href = '/login';
    }
  }
}
</script>
<style scoped>
.el-container {
  width: 100%;
  height: 100%;
}

.el-container > .el-header {
  height: 15%;
  width: 100%;
  background-color: #545c64;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.el-container > .el-header .logo {
  border-radius: 50%;
  height: 100%;
}

.el-container > .el-header .info {
  margin-left: 20px;

  color: white;

}

.el-container > .el-header > div {
  display: flex;
  align-items: center;
  height: 100%;
}

.el-aside {
  height: 100%;
}

.el-menu {
  height: 100%;
}
</style>